<?php
class CategoryController extends HomeController{
    public function listAction(){
        // Yaf_Dispatcher::getInstance()->disableView();
        $id = Request::asget(3,'id',1);
        $model = new CategoryModel;
        $data = $model->where(['id'=>$id])->one();
        $this->_view->category = $data;

        $model = new ArticleModel;
        $data = $model->order('id DESC')->where(['category' => $id])->limit(0,20)->select();
        $this->_view->articles = $data;

        $count = $model->where(['category' => $id])->count();
        $this->_view->count = $count;
    }
    public function pageAction(){
        Yaf_Dispatcher::getInstance()->disableView();
        $page = Request::aspost(3,'page',0);
        $model = new ArticleModel;
        $data = $model->order('id DESC')->limit($page,20)->select();
        $_data = [
            'articles' => $data,
        ];
        $html = $this->render("page",$_data);
        echo $html;      
    }
}